home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 2 / ads / a-nudira < prev    next >
Text File  |  1996-02-12  |  3KB  |  77 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --         A D A . N U M E R I C S . D I S C R E T E _ R A N D O M          --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.8 $                              --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18. with Interfaces;
  19.  
  20. generic
  21.    type Result_Subtype is (<>);
  22.  
  23. package Ada.Numerics.Discrete_Random is
  24.  
  25.    --  Basic facilities.
  26.  
  27.    type Generator is limited private;
  28.  
  29.    function Random (Gen : Generator) return Result_Subtype;
  30.  
  31.    procedure Reset (Gen : Generator);
  32.    procedure Reset (Gen : Generator; Initiator : Integer);
  33.  
  34.    --  Advanced facilities.
  35.  
  36.    type State is private;
  37.  
  38.    procedure Save  (Gen : Generator; To_State   : out State);
  39.    procedure Reset (Gen : Generator; From_State : State);
  40.  
  41.    Max_Image_Width : constant := 80;
  42.  
  43.    function Image (Of_State    : State)  return String;
  44.    function Value (Coded_State : String) return State;
  45.  
  46. private
  47.    subtype Int is Interfaces.Integer_32;
  48.    subtype Rst is Result_Subtype;
  49.  
  50.    type Flt is digits 14;
  51.  
  52.    RstF : constant Flt := Flt (Rst'Pos (Rst'First));
  53.    RstL : constant Flt := Flt (Rst'Pos (Rst'Last));
  54.  
  55.    Offs : constant Flt := RstF + 0.5;
  56.  
  57.    K1   : constant := 94_833_359;
  58.    K1F  : constant := 94_833_359.0;
  59.    K2   : constant := 47_416_679;
  60.    K2F  : constant := 47_416_679.0;
  61.    Scal : constant Flt := (RstL - RstF + 1.0) / (K1F * K2F);
  62.  
  63.    type State is record
  64.       X1  : Int := 2999 ** 2;
  65.       X2  : Int := 1439 ** 2;
  66.       P   : Int := K1;
  67.       Q   : Int := K2;
  68.       FP  : Flt := K1F;
  69.       Scl : Flt := Scal;
  70.    end record;
  71.  
  72.    type Generator is limited record
  73.       Gen_State : State;
  74.    end record;
  75.  
  76. end Ada.Numerics.Discrete_Random;
  77.